const express = require("express");
const cors = require("cors");


const app = express();
//配置静态资源
app.use(express.static("./public"))
// app.use(express.static("../src"))
app.use(express.static("../dist"))

//拦截器  cors
// app.all("*", function (req, res, next) {
//     res.setHeader("access-control-allow-origin", "*");
//     next();
// })
app.use(cors());

//配置中间件
//解决 post请求,拿不到body的数据
app.use(express.urlencoded({ extended: false }));
app.use(express.json());

//配置路由
app.use("/account", require("./routers/accountRouter"));
//产品
app.use("/prod", require("./routers/prodRouter"));


app.listen(80, function () {
    console.log("启动服务器完毕!");
})